package cn.wx.scholar.neo4j.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.wx.common.persistence.base.BaseController;
import cn.wx.common.persistence.web.ResponseData;
import cn.wx.scholar.neo4j.entity.qo.Neo4jPaperQ;
import cn.wx.scholar.neo4j.service.Neo4jPaperService;

/**
 * @description : Paper 控制器 ---------------------------------
 * @author
 * @since 2018-07-13
 */
@RestController
@RequestMapping("/sholar/neo4j/paper")
public class Neo4jPaperController extends BaseController {

	@Autowired
    private Neo4jPaperService neo4jPaperService;

	/**
	 * 根据专家的Id获取该专家所有的论文数据，除掉会议数据
	 * 
	 * @param id
	 * @return
	 */
    @RequestMapping(value = "/getPapersByExpertId", method = RequestMethod.POST)
	public ResponseData getPapersByExpertId(Neo4jPaperQ neo4jPaperQ){
		return success(neo4jPaperService.getPapersByExpertId(neo4jPaperQ));
    }
    

	/**
	 * 根据论文的Id获取该论文的详情数据
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/getPapersDetail", method = RequestMethod.POST)
	public ResponseData getPapersDetailById(@RequestParam(value = "id") Long id) {
		return success(neo4jPaperService.findPaperDetailById(id));
	}
	
	/**
	 * 根据论文的Id获取该论文的详情数据：包括期刊、会议
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/findOnePaper", method = RequestMethod.POST)
	public ResponseData findOnePaper(@RequestParam(value = "id") Long id) {
		return success(neo4jPaperService.findOnePaper(id));
	}
	
	/**
	 * 按领域关键词统计论文数量
	 */
	@RequestMapping(value = "/statisticsPaperByPos", method = RequestMethod.POST)
	public ResponseData statisticsPaperByPos(@RequestParam(value = "fos") String fos) {
		return success(neo4jPaperService.statisticsPaperByPos(fos));
	}
	
	/**
	 * 统计某个专家对于每一个fos关键词历年的论文数量（鼠标点击某年，可以显示某年论文数量）
	 * @param fos
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/statisticsPaperByExpertPos", method = RequestMethod.POST)
	public ResponseData statisticsPaperByExpertPos(@RequestParam(value ="fos[]") List<String> fos, 
			@RequestParam(value = "id")Long id) {
		return success(neo4jPaperService.statisticsPaperByExpertPos(fos, id));
	}
	
}
